package com.dingreading.cloud.admin.service.impl;

import com.dingreading.cloud.admin.entity.table.NjTicketUserLogTableDef;
import com.dingreading.cloud.common.util.PageUtil;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryCondition;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.dingreading.cloud.admin.entity.NjTicketUserLog;
import com.dingreading.cloud.admin.mapper.NjTicketUserLogMapper;
import com.dingreading.cloud.admin.service.NjTicketUserLogService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 *  服务层实现。
 *
 * @author Administrator
 * @since 2025-01-03
 */
@Service
public class NjTicketUserLogServiceImpl extends BaseServiceImpl<NjTicketUserLogMapper, NjTicketUserLog, NjTicketUserLogTableDef> implements NjTicketUserLogService {

    @Override
    protected NjTicketUserLogTableDef getTable() {
        return NjTicketUserLogTableDef.njTicketUserLog;
    }

    @Override
    public Page<NjTicketUserLog> pageList(PageUtil pageUtil, String keyword) {
        QueryCondition condition = QueryCondition.createEmpty();
        if (StringUtils.isNotBlank(keyword))
            condition.and(table.corpName.like(keyword)
                    .or(table.name.like(keyword))
                    .or(table.phone.like(keyword))
                    .or(table.type.like(keyword))
            );
        QueryWrapper wrapper = QueryWrapper.create()
                .where(condition)
                .orderBy(table.id.desc());

        return getMapper().paginate(Page.of(pageUtil.getPage(), pageUtil.getRows()), wrapper);
    }
}
